import http from "@/utils/http";
import { AxiosRequestConfig } from "axios";

export interface GetMetricsBoardGlobalConditions_ {
  /**
   * @description boardId
   * @format int32
   */
  boardId: number;
}
export interface PutMetricsBoardById_ {
  /**
   * @description 看板的id
   */
  id: number;
}

export class MetricsBoard {
  /**
   * 新建指标看板
   *
   * @tags 指标看板模块
   * @request POST: /metrics-board
   * @secure
   */
  postMetricsBoard = (metricsBoardDto: defs.MetricsBoardDto, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityString>({
      url: `/metrics-board`,
      method: "POST",
      data: metricsBoardDto,
      ...params,
    });

  /**
   * 预览||刷新指标看板卡片
   *
   * @tags 指标看板模块
   * @request POST: /metrics-board/card/preview
   * @secure
   */
  postMetricsBoardCardPreview = (cardPreviewDTO: defs.MetricsBoardCardPreviewDTO, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityMetricsCardDto>({
      url: `/metrics-board/card/preview`,
      method: "POST",
      data: cardPreviewDTO,
      ...params,
    });

  /**
   * 复制指标看板
   *
   * @tags 指标看板模块
   * @request POST: /metrics-board/duplicate
   * @secure
   */
  postMetricsBoardDuplicate = (duplicateBoardDto: defs.DuplicateBoardDto, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityString>({
      url: `/metrics-board/duplicate`,
      method: "POST",
      data: duplicateBoardDto,
      ...params,
    });

  /**
   * 获取可用的全局条件
   *
   * @tags 指标看板模块
   * @request GET: /metrics-board/globalConditions
   * @secure
   */
  getMetricsBoardGlobalConditions = (
    query: { boardId: number } | GetMetricsBoardGlobalConditions_,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityMetricsBoardGlobalConsVO>({
      url: `/metrics-board/globalConditions`,
      method: "GET",
      params: query,
      ...params,
    });

  /**
   * 查询单个指标看板的详情
   *
   * @tags 指标看板模块
   * @request POST: /metrics-board/view
   * @secure
   */
  postMetricsBoardView = (metricsBoardView: defs.MetricsBoardViewDto, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityMetricsBoardVO>({
      url: `/metrics-board/view`,
      method: "POST",
      data: metricsBoardView,
      ...params,
    });

  /**
   * 修改指标看板
   *
   * @tags 指标看板模块
   * @request PUT: /metrics-board/{id}
   * @secure
   */
  putMetricsBoardById = (
    { id }: { id: number } | PutMetricsBoardById_,
    metricsBoardDto: defs.MetricsBoardDto,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityString>({
      url: `/metrics-board/${id}`,
      method: "PUT",
      data: metricsBoardDto,
      ...params,
    });
}

export default new MetricsBoard();
